package com.idiot.operationbackend.controller.interactive;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageInfo;
import com.idiot.operationbackend.entity.Account;
import com.idiot.operationbackend.entity.PopularizeQrCode;
import com.idiot.operationbackend.entity.QrCode;
import com.idiot.operationbackend.entity.Scene;
import com.idiot.operationbackend.service.facade.AccountService;
import com.idiot.operationbackend.service.facade.QrCodeService;
import com.idiot.operationbackend.service.facade.WeChatService;
import com.idiot.operationbackend.service.impl.PopularQrCodeService;
import com.idiot.operationbackend.support.*;
import com.idiot.operationbackend.util.JwtTokenUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.time.LocalDateTime;

/**
 * 二维码
 * @author wang xiao
 * @date Created in 18:03 2020/9/21
 */
@RestController
@RequestMapping("/popularQr")
@Api(value = "PopularQrCodeController", tags ="推广二维码")
public class PopularQrCodeController {


    private final Logger logger = LoggerFactory.getLogger(PopularQrCodeController.class);

    @Autowired
    private PopularQrCodeService popularQrCodeService;


    @Autowired
    private WeChatService weChatService;

    @PostMapping("/page")
    @ApiOperation(value = "推广场景列表")
    public ResponseEntity<JsonResult<PageInfo<SceneVO>>> page(@RequestHeader String token,
                                                              @RequestBody ScanScene scanScene) {

        return ResponseEntity.ok(JsonResult.success(popularQrCodeService.scenePage(scanScene)));
    }

    @PostMapping("")
    @ApiOperation(value = "新增推广场景")
    public ResponseEntity<JsonResult<String>> add(@RequestHeader String token,
                                                              @RequestBody Scene scanScene) {

        return ResponseEntity.ok(JsonResult.success(popularQrCodeService.add(scanScene)));
    }

    @PostMapping("/popularQrCode")
    @ApiOperation(value = "推广场景下新增推广二维码信息")
    public ResponseEntity<JsonResult<String>> addPopularQrCode(@RequestHeader String token,
                                                               @RequestBody PopularizeQrCode popularizeQrCode) {

        return ResponseEntity.ok(JsonResult.success(popularQrCodeService.addPopularizeQrCode(popularizeQrCode)));
    }

    @PutMapping("/popularQrCode")
    @ApiOperation(value = "修改推广二维码信息")
    public ResponseEntity<JsonResult> editPopularQrCode(@RequestHeader String token,
                                                               @RequestBody PopularizeQrCode popularizeQrCode) {
        popularQrCodeService.editPopularizeQrCode(popularizeQrCode);
        return ResponseEntity.ok(JsonResult.success(popularizeQrCode.getId()));
    }









}
